package com.woniuxy.session.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpSession;

/**
 * @Author: linKe
 * @Date: 2022/1/6 10:10
 * @FileName: SessionController
 * @version: 1.0
 * @Description: session模拟
 * session 存储在redis中测试 controller
 */
@RestController
@RequestMapping("/session")
public class SessionController {
    @Value("${server.port}")
    private String port;

    @GetMapping("/login")
    public String login(HttpSession httpSession){
        httpSession.setAttribute("name","session测试");
        String name = (String)httpSession.getAttribute("name");
        return port+name;
    }
    @GetMapping("/test")
    public String test(HttpSession httpSession){
        String name = (String)httpSession.getAttribute("name");
        return port+name;
    }

}
